package model

type User struct {
    ID int `gorm:"primary_key" json:"id"`
    Name string `json:"name"`
    Password string `json:"password"`
}

func (u *User) TableName() string {
    return "user"
}

func (u *User) GetUserIDByPwd(username, password string) (userID string) {
    // use the db conn 
    // write your own user authentication logic
    // like:
    // db.Where("name = ? AND password = ?", username, password).First(u)
    // userID = u.ID

    // test account: admin admin
    if username == "admin" && password == "admin" {
        userID = "admin"
    }

    return
}

type ProtoUserRes struct {
    Result ProtoUser `json:"result"`
}

type ProtoUser struct {
    Id                  int64   `json:"id"` 				   //ID
    Uid          		string  `json:"uid"`            	   //UID
    Type                int32   `json:"type"`                //类型
    Nickname            string  `json:"nickname"` 	           //昵称
    HeadImg             string  `json:"head_img"` 	           //用户头像
    IsAdmin             int32   `json:"is_admin"` 	       //是否管理员
    IsVip               int32   `json:"is_vip"` 	           //是否会员
    Phone               string  `json:"phone"` 	               //用户头像
    Password            string  `json:"password"`                  //密码
    Status              int32   `json:"status"` 	           //状态
    Reward              int64   `json:"reward"` 	           //奖励
}